/*     */ package com.zimbra.cs.service.mail;
/*     */ 
/*     */ import com.zimbra.common.calendar.Geo;
/*     */ import com.zimbra.common.calendar.ParsedDateTime;
/*     */ import com.zimbra.common.calendar.ParsedDuration;
/*     */ import com.zimbra.common.localconfig.KnownKey;
/*     */ import com.zimbra.common.localconfig.LC;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.soap.Element.Disposition;
/*     */ import com.zimbra.common.util.Log;
/*     */ import com.zimbra.common.util.LogFactory;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.mailbox.Appointment;
/*     */ import com.zimbra.cs.mailbox.CalendarItem;
/*     */ import com.zimbra.cs.mailbox.CalendarItem.AlarmData;
/*     */ import com.zimbra.cs.mailbox.CalendarItem.Instance;
/*     */ import com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException;
/*     */ import com.zimbra.cs.mailbox.Mailbox;
/*     */ import com.zimbra.cs.mailbox.OperationContext;
/*     */ import com.zimbra.cs.mailbox.Task;
/*     */ import com.zimbra.cs.mailbox.calendar.Invite;
/*     */ import com.zimbra.cs.mailbox.calendar.InviteInfo;
/*     */ import com.zimbra.cs.mailbox.calendar.RecurId;
/*     */ import com.zimbra.cs.mailbox.calendar.ZOrganizer;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CacheToXML;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CalSummaryCache;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CalSummaryCache.CalendarDataResult;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CalendarData;
/*     */ import com.zimbra.cs.mailbox.calendar.cache.CalendarItemData;
/*     */ import com.zimbra.cs.service.util.ItemId;
/*     */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*     */ import com.zimbra.soap.ZimbraSoapContext;
/*     */ import java.util.Collection;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class GetCalendarItemSummaries
/*     */   extends CalendarRequest
/*     */ {
/*  63 */   private static Log mLog = LogFactory.getLog(GetCalendarItemSummaries.class);
/*     */   
/*  65 */   private static final String[] TARGET_FOLDER_PATH = { "l" };
/*  66 */   private static final String[] RESPONSE_ITEM_PATH = new String[0];
/*     */   private static final String DEFAULT_FOLDER = "-1";
/*     */   
/*     */   protected String[] getProxiedIdPath(Element request) {
/*  70 */     return TARGET_FOLDER_PATH;
/*     */   }
/*     */   
/*     */   protected boolean checkMountpointProxy(Element request)
/*     */   {
/*  75 */     return true;
/*     */   }
/*     */   
/*     */   protected String[] getResponseItemPath()
/*     */   {
/*  80 */     return RESPONSE_ITEM_PATH;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final long MSEC_PER_DAY = 86400000L;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final long MAX_PERIOD_SIZE_IN_DAYS = 200L;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   static EncodeCalendarItemResult encodeCalendarItemInstances(ZimbraSoapContext lc, OperationContext octxt, CalendarItem calItem, Account acct, long rangeStart, long rangeEnd, boolean newFormat)
/*     */     throws ServiceException
/*     */   {
/* 111 */     EncodeCalendarItemResult toRet = new EncodeCalendarItemResult();
/* 112 */     ItemIdFormatter ifmt = new ItemIdFormatter(lc);
/* 113 */     Account authAccount = getAuthenticatedAccount(lc);
/* 114 */     boolean hidePrivate = !calItem.allowPrivateAccess(authAccount, lc.isUsingAdminPrivileges());
/*     */     try
/*     */     {
/*     */       boolean expandRanges;
/* 118 */       if ((calItem instanceof Task)) {
/* 119 */         boolean expandRanges = true;
/* 120 */         if ((rangeStart == -1L) && (rangeEnd == -1L)) {
/* 121 */           rangeStart = Long.MIN_VALUE;
/* 122 */           rangeEnd = Long.MAX_VALUE;
/*     */         }
/*     */       } else {
/* 125 */         expandRanges = (rangeStart != -1L) && (rangeEnd != -1L) && (rangeStart < rangeEnd);
/*     */       }
/*     */       
/* 128 */       boolean isAppointment = calItem instanceof Appointment;
/*     */       
/*     */ 
/* 131 */       if ((isAppointment) && (expandRanges)) {
/* 132 */         CalendarItemData calItemData = CalSummaryCache.reloadCalendarItemOverRange(calItem, rangeStart, rangeEnd);
/* 133 */         if (calItemData != null) {
/* 134 */           int numInstances = calItemData.getNumInstances();
/* 135 */           if (numInstances > 0) {
/* 136 */             Element calItemElem = CacheToXML.encodeCalendarItemData(lc, ifmt, calItemData, !hidePrivate, !newFormat);
/* 137 */             toRet.element = calItemElem;
/* 138 */             toRet.numInstancesExpanded = numInstances;
/*     */           }
/*     */         }
/* 141 */         return toRet;
/*     */       }
/*     */       
/*     */ 
/* 145 */       Element calItemElem = null;
/*     */       
/* 147 */       Invite defaultInvite = calItem.getDefaultInviteOrNull();
/*     */       
/* 149 */       if (defaultInvite == null) {
/* 150 */         mLog.info("Could not load defaultinfo for calendar item with id=" + calItem.getId() + " SKIPPING");
/* 151 */         return toRet;
/*     */       }
/*     */       
/* 154 */       ParsedDuration defDuration = defaultInvite.getEffectiveDuration();
/*     */       
/*     */ 
/* 157 */       if ((defDuration == null) && (!defaultInvite.isTodo())) {
/* 158 */         if (defaultInvite.isAllDayEvent()) {
/* 159 */           defDuration = ParsedDuration.ONE_DAY;
/*     */         } else {
/* 161 */           defDuration = ParsedDuration.ONE_SECOND;
/*     */         }
/*     */       }
/* 164 */       long defDurationMsecs = 0L;
/* 165 */       if ((defaultInvite.getStartTime() != null) && (defDuration != null)) {
/* 166 */         ParsedDateTime s = defaultInvite.getStartTime();
/* 167 */         long et = s.add(defDuration).getUtcTime();
/* 168 */         defDurationMsecs = et - s.getUtcTime();
/*     */       }
/*     */       
/* 171 */       String defaultFba = null;
/* 172 */       if ((calItem instanceof Appointment)) {
/* 173 */         defaultFba = ((Appointment)calItem).getEffectiveFreeBusyActual(defaultInvite, null);
/*     */       }
/*     */       
/* 176 */       String defaultPtSt = calItem.getEffectivePartStat(defaultInvite, null);
/*     */       
/* 178 */       CalendarItem.AlarmData alarmData = calItem.getAlarmData();
/*     */       
/*     */ 
/* 181 */       int numInRange = 0;
/*     */       long alarmTime;
/* 183 */       long alarmInst; if (expandRanges) {
/* 184 */         Collection<CalendarItem.Instance> instances = calItem.expandInstances(rangeStart, rangeEnd, true);
/* 185 */         alarmTime = 0L;
/* 186 */         alarmInst = 0L;
/* 187 */         if (alarmData != null) {
/* 188 */           alarmTime = alarmData.getNextAt();
/* 189 */           alarmInst = alarmData.getNextInstanceStart();
/*     */         }
/* 191 */         for (CalendarItem.Instance inst : instances) {
/*     */           try {
/* 193 */             InviteInfo invId = inst.getInviteInfo();
/* 194 */             Invite inv = calItem.getInvite(invId.getMsgId(), invId.getComponentId());
/* 195 */             boolean showAll = (!hidePrivate) || (inv.isPublic());
/*     */             
/*     */ 
/*     */ 
/* 199 */             ParsedDuration invDuration = inv.getEffectiveDuration();
/* 200 */             long instStart = inst.getStart();
/*     */             
/*     */ 
/* 203 */             long startOrAlarm = instStart == alarmInst ? alarmTime : instStart;
/*     */             
/*     */ 
/*     */ 
/* 207 */             if (invDuration == null) {
/* 208 */               if (inv.isAllDayEvent()) {
/* 209 */                 invDuration = ParsedDuration.ONE_DAY;
/*     */               } else
/* 211 */                 invDuration = ParsedDuration.ONE_SECOND;
/*     */             }
/* 213 */             if ((!inst.hasStart()) || ((startOrAlarm < rangeEnd) && (invDuration.addToTime(instStart) > rangeStart)))
/*     */             {
/* 215 */               numInRange++;
/*     */             } else {
/*     */               continue;
/*     */             }
/*     */             
/* 220 */             if (calItemElem == null) {
/* 221 */               calItemElem = lc.createElement(isAppointment ? "appt" : "task");
/*     */               
/* 223 */               if (showAll)
/*     */               {
/* 225 */                 ToXML.recordItemTags(calItemElem, calItem, octxt);
/*     */               }
/*     */               
/*     */ 
/* 229 */               if (inv.hasOrganizer()) {
/* 230 */                 ZOrganizer org = inv.getOrganizer();
/* 231 */                 org.toXml(calItemElem);
/*     */               }
/*     */               
/* 234 */               calItemElem.addAttribute("x_uid", calItem.getUid());
/* 235 */               calItemElem.addAttribute("uid", calItem.getUid());
/*     */             }
/*     */             
/* 238 */             Element instElt = calItemElem.addElement("inst");
/*     */             
/* 240 */             if (showAll) {
/* 241 */               if ((isAppointment) && (inv.isEvent())) {
/* 242 */                 String instFba = ((Appointment)calItem).getEffectiveFreeBusyActual(inv, inst);
/* 243 */                 if ((instFba != null) && ((!instFba.equals(defaultFba)) || (inst.isException())))
/* 244 */                   instElt.addAttribute("fba", instFba);
/*     */               }
/* 246 */               String instPtSt = calItem.getEffectivePartStat(inv, inst);
/* 247 */               if ((!defaultPtSt.equals(instPtSt)) || (inst.isException())) {
/* 248 */                 instElt.addAttribute("ptst", instPtSt);
/*     */               }
/*     */             }
/* 251 */             if (inst.hasStart()) {
/* 252 */               instElt.addAttribute("s", instStart);
/* 253 */               if (inv.isAllDayEvent()) {
/* 254 */                 instElt.addAttribute("tzo", inst.getStartTzOffset());
/*     */               }
/*     */             }
/*     */             
/* 258 */             if ((inst.isException()) && (inv.hasRecurId())) {
/* 259 */               RecurId rid = inv.getRecurId();
/* 260 */               instElt.addAttribute("ridZ", rid.getDtZ());
/*     */             } else {
/* 262 */               instElt.addAttribute("ridZ", inst.getRecurIdZ());
/*     */             }
/*     */             
/* 265 */             if (inst.isException())
/*     */             {
/* 267 */               instElt.addAttribute("ex", true);
/*     */               
/* 269 */               instElt.addAttribute("invId", ifmt.formatItemId(calItem, inst.getMailItemId()));
/* 270 */               instElt.addAttribute("compNum", inst.getComponentNum());
/*     */               
/* 272 */               if (showAll)
/*     */               {
/* 274 */                 String frag = inv.getFragment();
/* 275 */                 if ((frag != null) && (!frag.equals(""))) {
/* 276 */                   instElt.addAttribute("fr", frag, Element.Disposition.CONTENT);
/*     */                 }
/* 278 */                 if (inv.getPriority() != null) {
/* 279 */                   instElt.addAttribute("priority", inv.getPriority());
/*     */                 }
/* 281 */                 if (inv.isEvent()) {
/* 282 */                   if (inv.getFreeBusy() != null)
/* 283 */                     instElt.addAttribute("fb", inv.getFreeBusy());
/* 284 */                   if (inv.getTransparency() != null) {
/* 285 */                     instElt.addAttribute("transp", inv.getTransparency());
/*     */                   }
/*     */                 }
/* 288 */                 if ((inv.isTodo()) && 
/* 289 */                   (inv.getPercentComplete() != null)) {
/* 290 */                   instElt.addAttribute("percentComplete", inv.getPercentComplete());
/*     */                 }
/*     */                 
/* 293 */                 if (inv.getName() != null) {
/* 294 */                   instElt.addAttribute("name", inv.getName());
/*     */                 }
/* 296 */                 if (inv.getLocation() != null) {
/* 297 */                   instElt.addAttribute("loc", inv.getLocation());
/*     */                 }
/* 299 */                 List<String> categories = inv.getCategories();
/* 300 */                 if (categories != null) {
/* 301 */                   for (String cat : categories) {
/* 302 */                     instElt.addElement("category").setText(cat);
/*     */                   }
/*     */                 }
/* 305 */                 Geo geo = inv.getGeo();
/* 306 */                 if (geo != null) {
/* 307 */                   geo.toXml(instElt);
/*     */                 }
/* 309 */                 if (inv.hasOtherAttendees()) {
/* 310 */                   instElt.addAttribute("otherAtt", true);
/*     */                 }
/* 312 */                 if (inv.hasAlarm()) {
/* 313 */                   instElt.addAttribute("alarm", true);
/*     */                 }
/*     */               }
/* 316 */               instElt.addAttribute("isOrg", inv.isOrganizer());
/*     */               
/* 318 */               if (inv.isTodo()) {
/* 319 */                 if (inst.hasEnd()) {
/* 320 */                   instElt.addAttribute("dueDate", inst.getEnd());
/* 321 */                   if (inv.isAllDayEvent()) {
/* 322 */                     instElt.addAttribute("tzoDue", inst.getEndTzOffset());
/*     */                   }
/*     */                 }
/* 325 */               } else if ((inst.hasStart()) && (inst.hasEnd())) {
/* 326 */                 instElt.addAttribute(newFormat ? "dur" : "d", inst.getEnd() - inst.getStart());
/*     */               }
/*     */               
/*     */ 
/*     */ 
/*     */ 
/* 332 */               if (inv.getStatus() != null) {
/* 333 */                 instElt.addAttribute("status", inv.getStatus());
/*     */               }
/* 335 */               if (inv.getClassProp() != null) {
/* 336 */                 instElt.addAttribute("class", inv.getClassProp());
/*     */               }
/* 338 */               if (inv.isAllDayEvent())
/* 339 */                 instElt.addAttribute("allDay", true);
/* 340 */               if (inv.isDraft())
/* 341 */                 instElt.addAttribute("draft", true);
/* 342 */               if (inv.isNeverSent())
/* 343 */                 instElt.addAttribute("neverSent", true);
/* 344 */               if (inv.isRecurrence()) {
/* 345 */                 instElt.addAttribute("recur", true);
/*     */               }
/* 347 */             } else if (inv.isTodo()) {
/* 348 */               if (inst.hasEnd()) {
/* 349 */                 instElt.addAttribute("dueDate", inst.getEnd());
/* 350 */                 if (inv.isAllDayEvent()) {
/* 351 */                   instElt.addAttribute("tzoDue", inst.getEndTzOffset());
/*     */                 }
/*     */                 
/*     */               }
/*     */             }
/* 356 */             else if ((inst.hasStart()) && (inst.hasEnd()) && (defDurationMsecs != inst.getEnd() - inst.getStart())) {
/* 357 */               instElt.addAttribute(newFormat ? "dur" : "d", inst.getEnd() - inst.getStart());
/*     */             }
/*     */           }
/*     */           catch (MailServiceException.NoSuchItemException e)
/*     */           {
/* 362 */             mLog.info("Error could not get instance " + inst.getMailItemId() + "-" + inst.getComponentNum() + " for appt " + calItem.getId(), e);
/*     */           }
/*     */         }
/*     */       }
/*     */       
/*     */ 
/*     */ 
/* 369 */       if ((!expandRanges) || (numInRange > 0)) {
/* 370 */         boolean showAll = (!hidePrivate) || (defaultInvite.isPublic());
/* 371 */         if (calItemElem == null) {
/* 372 */           calItemElem = lc.createElement(isAppointment ? "appt" : "task");
/*     */           
/* 374 */           calItemElem.addAttribute("x_uid", calItem.getUid());
/* 375 */           calItemElem.addAttribute("uid", calItem.getUid());
/*     */           
/* 377 */           if (showAll)
/*     */           {
/* 379 */             ToXML.recordItemTags(calItemElem, calItem, octxt);
/*     */           }
/*     */           
/*     */ 
/* 383 */           if (defaultInvite.hasOrganizer()) {
/* 384 */             ZOrganizer org = defaultInvite.getOrganizer();
/* 385 */             org.toXml(calItemElem);
/*     */           }
/*     */         }
/*     */         
/* 389 */         if (showAll) {
/* 390 */           if (alarmData != null) {
/* 391 */             ToXML.encodeAlarmData(calItemElem, calItem, alarmData);
/*     */           }
/* 393 */           String defaultPriority = defaultInvite.getPriority();
/* 394 */           if (defaultPriority != null)
/* 395 */             calItemElem.addAttribute("priority", defaultPriority);
/* 396 */           calItemElem.addAttribute("ptst", defaultPtSt);
/* 397 */           if (defaultInvite.isEvent()) {
/* 398 */             calItemElem.addAttribute("fb", defaultInvite.getFreeBusy());
/* 399 */             calItemElem.addAttribute("fba", defaultFba);
/* 400 */             calItemElem.addAttribute("transp", defaultInvite.getTransparency());
/*     */           }
/* 402 */           if (defaultInvite.isTodo()) {
/* 403 */             String pctComplete = defaultInvite.getPercentComplete();
/* 404 */             if (pctComplete != null) {
/* 405 */               calItemElem.addAttribute("percentComplete", pctComplete);
/*     */             }
/*     */           }
/* 408 */           calItemElem.addAttribute("name", defaultInvite.getName());
/* 409 */           calItemElem.addAttribute("loc", defaultInvite.getLocation());
/*     */           
/* 411 */           List<String> categories = defaultInvite.getCategories();
/* 412 */           if (categories != null) {
/* 413 */             for (String cat : categories) {
/* 414 */               calItemElem.addElement("category").setText(cat);
/*     */             }
/*     */           }
/* 417 */           Geo geo = defaultInvite.getGeo();
/* 418 */           if (geo != null) {
/* 419 */             geo.toXml(calItemElem);
/*     */           }
/*     */           
/* 422 */           String fragment = defaultInvite.getFragment();
/* 423 */           if (!fragment.equals("")) {
/* 424 */             calItemElem.addAttribute("fr", fragment, Element.Disposition.CONTENT);
/*     */           }
/* 426 */           if (defaultInvite.hasOtherAttendees()) {
/* 427 */             calItemElem.addAttribute("otherAtt", defaultInvite.hasOtherAttendees());
/*     */           }
/* 429 */           if (defaultInvite.hasAlarm()) {
/* 430 */             calItemElem.addAttribute("alarm", defaultInvite.hasAlarm());
/*     */           }
/*     */         }
/*     */         
/* 434 */         calItemElem.addAttribute("isOrg", defaultInvite.isOrganizer());
/* 435 */         calItemElem.addAttribute("id", ifmt.formatItemId(calItem));
/* 436 */         calItemElem.addAttribute("invId", ifmt.formatItemId(calItem, defaultInvite.getMailItemId()));
/*     */         
/* 438 */         calItemElem.addAttribute("compNum", defaultInvite.getComponentNum());
/* 439 */         calItemElem.addAttribute("l", ifmt.formatItemId(new ItemId(calItem.getMailbox().getAccountId(), calItem.getFolderId())));
/*     */         
/*     */ 
/* 442 */         calItemElem.addAttribute("status", defaultInvite.getStatus());
/* 443 */         calItemElem.addAttribute("class", defaultInvite.getClassProp());
/* 444 */         if (!defaultInvite.isTodo())
/* 445 */           calItemElem.addAttribute(newFormat ? "dur" : "d", defDurationMsecs);
/* 446 */         if (defaultInvite.isAllDayEvent())
/* 447 */           calItemElem.addAttribute("allDay", defaultInvite.isAllDayEvent());
/* 448 */         if (defaultInvite.isDraft())
/* 449 */           calItemElem.addAttribute("draft", defaultInvite.isDraft());
/* 450 */         if (defaultInvite.isNeverSent())
/* 451 */           calItemElem.addAttribute("neverSent", defaultInvite.isNeverSent());
/* 452 */         if (defaultInvite.isRecurrence())
/* 453 */           calItemElem.addAttribute("recur", defaultInvite.isRecurrence());
/* 454 */         if (calItem.hasExceptions()) {
/* 455 */           calItemElem.addAttribute("hasEx", true);
/*     */         }
/*     */         
/* 458 */         toRet.element = calItemElem;
/*     */       }
/* 460 */       toRet.numInstancesExpanded = numInRange;
/*     */     } catch (MailServiceException.NoSuchItemException e) {
/* 462 */       mLog.info("Error could not get default invite for calendar item: " + calItem.getId(), e);
/*     */     } catch (RuntimeException e) {
/* 464 */       mLog.info("Caught Exception " + e + " while getting summary info for calendar item: " + calItem.getId(), e);
/*     */     }
/*     */     
/* 467 */     return toRet;
/*     */   }
/*     */   
/*     */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*     */   {
/* 472 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 473 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 474 */     Account acct = getRequestedAccount(zsc);
/*     */     
/* 476 */     long rangeStart = request.getAttributeLong("s");
/* 477 */     long rangeEnd = request.getAttributeLong("e");
/*     */     
/* 479 */     if (rangeEnd < rangeStart) {
/* 480 */       throw ServiceException.INVALID_REQUEST("End time must be after Start time", null);
/*     */     }
/*     */     
/* 483 */     long days = (rangeEnd - rangeStart) / 86400000L;
/* 484 */     if (days > 200L) {
/* 485 */       throw ServiceException.INVALID_REQUEST("Requested range is too large (Maximum 200 days)", null);
/*     */     }
/*     */     
/*     */ 
/* 489 */     ItemId iidFolder = new ItemId(request.getAttribute("l", "-1"), zsc);
/*     */     
/* 491 */     Element response = getResponseElement(zsc);
/*     */     
/* 493 */     OperationContext octxt = getOperationContext(zsc, context);
/*     */     ItemIdFormatter ifmt;
/* 495 */     Iterator i$; CalSummaryCache.CalendarDataResult result; Iterator<CalendarItemData> itemIter; if (LC.calendar_cache_enabled.booleanValue()) {
/* 496 */       ifmt = new ItemIdFormatter(zsc);
/* 497 */       int folderId = iidFolder.getId();
/* 498 */       CalSummaryCache.CalendarDataResult result; Iterator<CalendarItemData> itemIter; if (folderId != -1) {
/* 499 */         result = mbox.getCalendarSummaryForRange(octxt, folderId, getItemType(), rangeStart, rangeEnd);
/*     */         
/* 501 */         if (result != null) {
/* 502 */           for (itemIter = result.data.calendarItemIterator(); itemIter.hasNext();) {
/* 503 */             CalendarItemData calItemData = (CalendarItemData)itemIter.next();
/* 504 */             int numInstances = calItemData.getNumInstances();
/* 505 */             if (numInstances > 0) {
/* 506 */               Element calItemElem = CacheToXML.encodeCalendarItemData(zsc, ifmt, calItemData, result.allowPrivateAccess, true);
/*     */               
/* 508 */               response.addElement(calItemElem);
/*     */             }
/*     */           }
/*     */         }
/*     */       } else {
/* 513 */         List<CalSummaryCache.CalendarDataResult> calDataResultList = mbox.getAllCalendarsSummaryForRange(octxt, getItemType(), rangeStart, rangeEnd);
/*     */         
/* 515 */         for (i$ = calDataResultList.iterator(); i$.hasNext();) { result = (CalSummaryCache.CalendarDataResult)i$.next();
/* 516 */           for (itemIter = result.data.calendarItemIterator(); itemIter.hasNext();) {
/* 517 */             CalendarItemData calItemData = (CalendarItemData)itemIter.next();
/* 518 */             int numInstances = calItemData.getNumInstances();
/* 519 */             if (numInstances > 0) {
/* 520 */               Element calItemElem = CacheToXML.encodeCalendarItemData(zsc, ifmt, calItemData, result.allowPrivateAccess, true);
/*     */               
/* 522 */               response.addElement(calItemElem);
/*     */             }
/*     */           }
/*     */         }
/*     */       }
/*     */     } else {
/* 528 */       Collection<CalendarItem> calItems = mbox.getCalendarItemsForRange(octxt, getItemType(), rangeStart, rangeEnd, iidFolder.getId(), null);
/*     */       
/* 530 */       for (CalendarItem calItem : calItems) {
/* 531 */         EncodeCalendarItemResult encoded = encodeCalendarItemInstances(zsc, octxt, calItem, acct, rangeStart, rangeEnd, false);
/*     */         
/* 533 */         if (encoded.element != null) {
/* 534 */           response.addElement(encoded.element);
/*     */         }
/*     */       }
/*     */     }
/* 538 */     return response;
/*     */   }
/*     */   
/*     */   static class EncodeCalendarItemResult
/*     */   {
/*     */     Element element;
/*     */     int numInstancesExpanded;
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetCalendarItemSummaries.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */